<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.hilaver.dzmis.Constants"%>
<%@ page import="com.hilaver.dzmis.service.impl.CtServiceImpl"%>
<%@ page import="com.hilaver.dzmis.service.impl.ProcurementServiceImpl"%>
<%@ page import="com.hilaver.dzmis.service.impl.I18nServiceImpl"%>
<%@ page import="com.hilaver.dzmis.codetable.CtBrand"%>
<%@ page import="com.hilaver.dzmis.codetable.CtAccessoryType"%>
<%@ page import="com.hilaver.dzmis.procurement.Procurement"%>
<%@ page import="com.hilaver.dzmis.product.ProductIdentification"%>
<%@ page import="com.hilaver.dzmis.product.ProductAccessoryButton"%>
<%@ page import="com.hilaver.dzmis.product.ProductAccessoryZip"%>
<%@ page import="com.hilaver.dzmis.product.ProductAccessoryOthers"%>
<%@ page import="com.hilaver.dzmis.basicinfo.BiAccessoryButton"%>
<%@ page import="com.hilaver.dzmis.web.servlet.AbstractBaseServlet" %>
<%
	Integer id = Integer.parseInt(request.getParameter("id"));
	CtServiceImpl cs = new CtServiceImpl();
	ProcurementServiceImpl ps = new ProcurementServiceImpl();
	I18nServiceImpl i18n = new I18nServiceImpl();
	Locale locale = (Locale) request.getSession().getAttribute(
			Constants.SESSION_LOCALE);
	ps.setLocale(locale);
	ps.setRealFileDir(AbstractBaseServlet.UPLOAD_TEMP_REAL_DIR);
	Procurement procurement = ps.getObj(id);
	Set<ProductIdentification> piSet = procurement
			.getProductIndentifications();
	List<ProductAccessoryButton> pabIsSpecialList = ps.getProductAccessoryButtonIsSpecial(piSet);
	List<ProductAccessoryButton> pabIsNotSpecialList = ps.getProductAccessoryButtonIsNotSpecial(piSet);
	
	List<ProductAccessoryZip> pazIsSpecialList = ps.getProductAccessoryZipIsSpecial(piSet);
	List<ProductAccessoryZip> pazIsNotSpecialList = ps.getProductAccessoryZipIsNotSpecial(piSet);
	
	List<ProductAccessoryOthers> paoIsSpecialList = ps.getProductAccessoryOthersIsSpecial(piSet);
	List<ProductAccessoryOthers> paoIsNotSpecialList = ps.getProductAccessoryOthersIsNotSpecial(piSet);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
<link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
<style type="test/css">

</style>
<title><%=procurement.getName()%>--<%=i18n.getShortMessage(locale, "ui.procurement.accessory") %></title>
</head>
<body>
<table cellspacing="0" id="the-table" style="width: 100%;">
	<tr>
		<td colspan="3" style="background:#eeeeee;text-align: center;">
			<b><%
				if(piSet.size() > 0){
					ProductIdentification pi = (ProductIdentification)piSet.toArray()[0];
					out.print(pi.getBiFranceCustomer().getName());
					if(pi.getBiFranceCustomer().getDepartment() != null){
						out.print("--" + pi.getBiFranceCustomer().getDepartment());
					}
					out.print("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
					out.print(procurement.getName());
					out.print("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
					out.print(pi.getPatronageNumer());
				}
			%></b>
		</td>
	</tr>
	<tr>
		<td colspan="3" style="background:#eeeeee;text-align: center;">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<b><%=i18n.getShortMessage(locale, "ui.reference.reference") %></b>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<%
				for(ProductIdentification pi : piSet){
					out.print(pi.getReference());
					out.print("&nbsp;&nbsp;&nbsp;&nbsp;");
				}
			%>
		</td>
	</tr>
	<tr>
		<td rowspan="6">
			<%for(ProductAccessoryOthers pao : paoIsSpecialList){ %>
				<img width="160px" src="../../_temp/<%=pao.getBiAccessoryOthers().getBindPhotoName() == null?"noimage.gif": pao.getBiAccessoryOthers().getBindPhotoName() %>"/>
			<%} %>
			<%for(ProductAccessoryOthers pao : paoIsNotSpecialList){ %>
				<img width="160px" src="../../_temp/<%=pao.getBiAccessoryOthers().getBindPhotoName() == null?"noimage.gif": pao.getBiAccessoryOthers().getBindPhotoName() %>"/>
			<%} %>
		</td>
		<td colspan="2">
			<b><%=i18n.getShortMessage(locale, "ui.productidentification.accessory") %>:</b>&nbsp;&nbsp;
			<%
				if(piSet.size() > 0){
					out.print(((ProductIdentification)piSet.toArray()[0]).getBiFranceCustomer().getName());
				}
			%>
		</td>
	</tr>
	
	<tr>
		<td style="width: 30%;">
			<%for(ProductAccessoryButton pab : pabIsSpecialList){ %>
				<b><%=i18n.getShortMessage(locale, "ui.accessorybutton.reference") %>(<%=pab.getUnitNumber()==null?"": pab.getUnitNumber()%>): </b>
				<%=pab.getBiAccessoryButton().getReference() %><br/>
			<%} %>
			
			<%for(ProductAccessoryZip paz : pazIsSpecialList){ %>
				<b><%=i18n.getShortMessage(locale, "ui.accessoryzip.reference") %>(<%=paz.getUnitNumber()==null?"": paz.getUnitNumber()%>): </b>
				<%=paz.getBiAccessoryZip().getReference() %><br/>
			<%} %>
			
			<%for(ProductAccessoryOthers pao : paoIsSpecialList){ %>
				<b><%=cs.getDescription(CtAccessoryType.class.getName(), pao.getBiAccessoryOthers().getCtAccessoryType(), locale) %>(<%=pao.getUnitNumber()==null?"":pao.getUnitNumber() %>): </b>&nbsp;&nbsp;
				<%=pao.getBiAccessoryOthers().getReference() %><br/>
			<%} %>
		</td>
		<td style="width: 35%;">
			<%for(ProductAccessoryButton pab : pabIsSpecialList){ %>
				<img width="100px" src="../../_temp/<%=pab.getBiAccessoryButton().getPhotoName() == null?"noimage.gif": pab.getBiAccessoryButton().getPhotoName() %>"/>
			<%} %>
			<%for(ProductAccessoryZip paz : pazIsSpecialList){ %>
				<img width="100px" src="../../_temp/<%=paz.getBiAccessoryZip().getHeadPhotoName() == null?"noimage.gif": paz.getBiAccessoryZip().getHeadPhotoName() %>"/>
				<img width="100px" src="../../_temp/<%=paz.getBiAccessoryZip().getBlockPhotoName() == null?"noimage.gif": paz.getBiAccessoryZip().getBlockPhotoName() %>"/>
			<%} %>
			<%for(ProductAccessoryOthers pao : paoIsSpecialList){ %>
				<img width="100px" src="../../_temp/<%=pao.getBiAccessoryOthers().getPhotoName() == null?"noimage.gif": pao.getBiAccessoryOthers().getPhotoName() %>"/>
			<%} %>
		</td>
	</tr>
	
	<tr>
		<td colspan="2">
			<b><%=i18n.getShortMessage(locale, "ui.productidentification.accessory") %>:</b>&nbsp;&nbsp;DZ
		</td>
	</tr>
	
	<tr>
		<td style="width: 30%;">
			<%for(ProductAccessoryButton pab : pabIsNotSpecialList){ %>
				<b><%=i18n.getShortMessage(locale, "ui.accessorybutton.reference") %>(<%=pab.getUnitNumber()==null?"": pab.getUnitNumber()%>): </b>
				<%=pab.getBiAccessoryButton().getReference() %><br/>
			<%} %>
			
			<%for(ProductAccessoryZip paz : pazIsNotSpecialList){ %>
				<b><%=i18n.getShortMessage(locale, "ui.accessoryzip.reference") %>(<%=paz.getUnitNumber()==null?"": paz.getUnitNumber()%>): </b>
				<%=paz.getBiAccessoryZip().getReference() %><br/>
			<%} %>
			
			<%for(ProductAccessoryOthers pao : paoIsNotSpecialList){ %>
				<b><%=cs.getDescription(CtAccessoryType.class.getName(), pao.getBiAccessoryOthers().getCtAccessoryType(), locale) %>(<%=pao.getUnitNumber()==null?"":pao.getUnitNumber() %>): </b>&nbsp;&nbsp;
				<%=pao.getBiAccessoryOthers().getReference() %><br/>
			<%} %>
		</td>
		<td style="width: 35%;">
			<%for(ProductAccessoryButton pab : pabIsNotSpecialList){ %>
				<img width="100px" src="../../_temp/<%=pab.getBiAccessoryButton().getPhotoName() == null?"noimage.gif": pab.getBiAccessoryButton().getPhotoName() %>"/>
			<%} %>
			<%for(ProductAccessoryZip paz : pazIsNotSpecialList){ %>
				<img width="100px" src="../../_temp/<%=paz.getBiAccessoryZip().getHeadPhotoName() == null?"noimage.gif": paz.getBiAccessoryZip().getHeadPhotoName() %>"/>
				<img width="100px" src="../../_temp/<%=paz.getBiAccessoryZip().getBlockPhotoName() == null?"noimage.gif": paz.getBiAccessoryZip().getBlockPhotoName() %>"/>
			<%} %>
			<%for(ProductAccessoryOthers pao : paoIsNotSpecialList){ %>
				<img width="100px" src="../../_temp/<%=pao.getBiAccessoryOthers().getPhotoName() == null?"noimage.gif": pao.getBiAccessoryOthers().getPhotoName() %>"/>
			<%} %>
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<b><%=i18n.getShortMessage(locale, "ui.accessoryothers.bindmethod") %>:</b>
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<%for(ProductAccessoryOthers pao : paoIsNotSpecialList){ %>
				<b><%=cs.getDescription(CtAccessoryType.class.getName(), pao.getBiAccessoryOthers().getCtAccessoryType(), locale) %>: </b><br/>
				<%=pao.getBiAccessoryOthers().getComment()%><br/>
			<%} %>
			<%for(ProductAccessoryOthers pao : paoIsSpecialList){ %>
				<b><%=cs.getDescription(CtAccessoryType.class.getName(), pao.getBiAccessoryOthers().getCtAccessoryType(), locale) %>: </b><br/>
				<%=pao.getBiAccessoryOthers().getComment()%><br/>
			<%} %>
		</td>
	</tr>
</table>
</body>
</html>